<head>
    <script src="../build/index.js"></script>
</head>

<body>
    <canvas id="app" width="400" height="800"></canvas>
    <div class="fps"></div>
    <style>
        .fps {
            position: absolute;
            font-size: 30px;
            top: 0;
            right: 100px;
            z-index: 2;
            background-color: white;
            color: red;
        }
    </style>


    <script>
        var $app = new Easycanvas.Painter();

        $app.register(document.getElementById('app'));
        $app.start();

        var $fpsBox = document.getElementsByClassName('fps')[0];
        $app.fpsHandler = function (fps) {
            if ($app.$perf && $app.$perf.preprocessTimeSpend) {
                $fpsBox.innerText = fps + 'fps,' + $app.$perf.preprocessTimeSpend + ',' + $app.$perf.paintTimeSpend;
            } else {
                $fpsBox.innerText = fps;
            }
        };

        Easycanvas.ImgLoader('https://raw.githubusercontent.com/c-zhuo/easycanvas/master/demos/G.png', function (img) {
            // create a Sprite
            window.Sprite1 = $app.add({
                name: 'root',
                content: {
                    img: img,
                },
                style: {
                    width: 250, height: 130,
                    cutLeft: 0, cutTop: 0, // source position, default 0
                    left: Easycanvas.Transition.ease(111, 422, 2500).loop(),
                    top: 80,
                    opacity: 0.1,
                    rotate: 20,
                    locate: 'center', // default center
                    zIndex: 1, // z-index of this image
                },
                events: {
                    eIndex: 2, // event-index of this image
                    mousemove: function (e) {
                        // "this" means this Sprite, as Sprite1
                        console.log(this, e);
                    },
                    // others: mousehold, mousedown, mouseout and touch events
                },
            });
        });
    </script>
</body>

